<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <script type="text/javascript" src="${ctx}/appjs/elec/pileOffline.js"></script>
    <link rel="stylesheet" href="${ctx}/statics/css/update.css">
    <link rel="stylesheet" href="${ctx}/statics/css/common.css">
    <link rel="stylesheet" href="${ctx}/libjs/plugins/bootstrap-table-pagejump/bootstrap-table-pagejump.css">
    <script src="${ctx}/libjs/plugins/bootstrap-table-pagejump/bootstrap-table-pagejump.js"></script>
    <%--<link rel="stylesheet" href="${ctx}/libjs/plugins/laydate/skins/laydate.css">--%>
    <link rel="stylesheet" href="${ctx}/libjs/plugins/laydate/laydate.css">
    <script src="${ctx}/libjs/plugins/laydate/laydate.js"></script>
    <link rel="stylesheet" href="${ctx}/libjs/plugins/bootStrap-table-fixed-column/bootstrap-table-fixed-columns.css">
    <script src="${ctx}/libjs/plugins/bootStrap-table-fixed-column/bootstrap-table-fixed-columns.js"></script>
    <style>
        .layui-card {
            box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .4) !important;
            text-align: center !important;
            border-top: 1px solid rgb(224, 224, 224);
        }

        .layui-card .layui-card-body {
            margin-top: 0 !important;
            font-size: 14px;
        }

        .layui-card .layui-card-header {
            background: rgba(30, 159, 255, 1);
            color: #fff;
        }

        .refreshTime span {
            font-weight: 700;
        }
    </style>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>设备管理</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>实时离线桩列表</strong>' +
            '</li>' +
            '</ol>';
    });

    var has_add = '';
    var has_edit = '';
    var has_delete = '';
    var StationManager_pileOffline_update = false;
</script>

<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="col-sm-12">
        <div class="ibox">
            <div class="ibox-body">
                <div class="row" style="padding-bottom: 15px !important;">
                    <div class="pull-left search ol-md-1">
                        <select type="text" class="form-control input-distance" name="sort" id="sort">
                            <option value="">排序</option>
                            <option value="1">离线时间由长至短</option>
                            <option value="2">离线桩由多至少</option>
                            <option value="3">离线桩品牌由多至少</option>
                        </select>
                    </div>
                    <div class="pull-left search ol-md-1">
                        <input class="form-control input-distance" placeholder="桩群名称" name="stationName"
                               id="stationName">
                    </div>
                    <div class="pull-left search ol-md-1">
                        <input class="form-control input-distance" placeholder="桩编号" name="pileNo" id="pileNo">
                    </div>
                    <div class="pull-left search ol-md-1">
                        <input class="form-control input-distance" placeholder="桩品牌" name="brandName" id="brandName">
                    </div>
                    <div class="pull-left search ol-md-1">
                        <select type="text" class="form-control input-distance" name="bizType" id="bizType"
                                style="margin: 0px 0px 0px 5.92px;">
                            <option value="">营业类型</option>
                            <option value="0">自营</option>
                            <option value="1">非自营</option>
                        </select>
                    </div>
                    <div class="pull-left search ol-md-1">
                        <select type="text" class="form-control input-distance" name="stationOperateStatus"
                                id="stationOperateStatus">
                            <option value="">桩群运营状态</option>
                            <option value="0">未上线</option>
                            <option value="1">上线</option>
                            <option value="2">下线</option>
                        </select>
                    </div>
                    <div class="pull-left search ol-md-1">
                        <select type="text" class="form-control input-distance" name="operateStatus" id="operateStatus">
                            <option value="">桩运营状态</option>
                            <option value="0">未上线</option>
                            <option value="1">上线</option>
                            <option value="2">下线</option>
                        </select>
                    </div>
                    <div class="pull-left search ol-md-1">
                        <select type="text" class="form-control input-distance" name="status" id="status">
                            <option value="">当前状态</option>
                            <option value="0">离线</option>
                            <option value="1">在线</option>
                        </select>
                    </div>
                </div>
                <div class="row" style="padding-bottom: 15px !important;">
                    <div class="pull-left search ol-md-1">
                        <input id="beginTime" name="beginTime" type="text"
                               class="form-control layer-date input-distance timeInput" autocomplete="false"
                               placeholder="开始时间">
                    </div>
                    <div class="pull-left search ol-md-1">
                        <input id="endTime" name="endTime" type="text"
                               class="form-control layer-date input-distance timeInput" autocomplete="false"
                               placeholder="结束时间">
                    </div>
                    <shiro:hasPermission name="StationManager_pileOffline_reload">
                        <button class="btn btn-success input-distance" onclick="pileOffline.reLoad()">查询</button>
                    </shiro:hasPermission>
                    <div class="pull-right search col-md-2">
                        <shiro:hasPermission name="StationManager_pileOffline_reload">
                            <div class="pull-right search col-md-10">
                                <button type="button" class="btn pull-right btn-success" onclick="pileOffline.reLoad()">
                                    手动刷新
                                </button>
                            </div>
                        </shiro:hasPermission>
                        <shiro:hasPermission name="StationManager_pileOffline_export">
                            <button type="button" class="btn pull-right btn-primary"
                                    onclick="pileOffline.exportPileOffline()">
                                导出
                            </button>
                        </shiro:hasPermission>
                    </div>
                </div>
                <div class="row"
                     style="display: flex;justify-content: space-evenly;padding-bottom: 0.1rem;margin-top: 1px !important;padding-top: 10px !important;">
                    <div class="col-md-2 ">
                        <div class="layui-card">
                            <div class="layui-card-header">当前离线总数</div>
                            <div class="layui-card-body" id="pileOffineCount">
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2 ">
                        <div class="layui-card">
                            <div class="layui-card-header">当前离线最多品牌</div>
                            <div class="layui-card-body" id="pileBrandMaxCount">

                            </div>
                        </div>
                    </div>
                    <div class="col-md-2 ">
                        <div class="layui-card">
                            <div class="layui-card-header">当前离线最多站点</div>
                            <div class="layui-card-body" id="pileStationMaxCount">
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2 ">
                        <div class="layui-card">
                            <div class="layui-card-header">当前在线率</div>
                            <div class="layui-card-body" id="pileOnlineRate">
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2 refreshTime" style="margin-top: 62px">
                        <span>上次刷新时间 :</span><span id="reloadTime" style="margin-left: 15px"></span>
                    </div>
                </div>
                <table id="exampleTable" data-mobile-responsive="true">
                </table>
            </div>
        </div>
    </div>
</div>

<shiro:hasPermission name="StationManager_pileOffline_update">
    <script>
        StationManager_pileOffline_update = true;
    </script>
</shiro:hasPermission>
<script type="text/javascript">

    var thisDate = new Date();
    var year = thisDate.getFullYear();
    var month = thisDate.getMonth() + 1;
    var date = thisDate.getDate();
    if (month < 10) {
        month = '0' + month
    }
    if (date < 10) {
        date = '0' + date
    }
    $('#beginTime').val(year + '-' + month + '-' + date + ' ' + '00:00:00');

    function getDate() {
        var date = new Date();
        var year = date.getFullYear();//年
        var month = date.getMonth() + 1;//月
        var day = date.getDate();//日

        if (month < 10) {
            month = "0" + month;
        }
        if (day < 10) {
            day = "0" + day;
        }

        var hour = date.getHours();
        var minute = date.getMinutes();
        var second = date.getSeconds();

        $("#reloadTime").html(year + "/" + month + "/" + day + "  " + hour + ":" + minute + ":" + second)
    }

    function selectPileOffineStatistics() {
        $.ajax({
            url: prefix + "/selectPileOffineStatistics",
            type: "GET",
            success: function (data) {
                console.log(data)
                if (data.status == 200) {
                    if (data.data.pileOffineCount != null && data.data.pileOffineCount != '') {
                        document.getElementById("pileOffineCount").innerHTML = data.data.pileOffineCount;
                    } else {
                        document.getElementById("pileOffineCount").innerHTML = "0";
                    }
                    if (data.data.pileBrandMaxCount != null && data.data.pileBrandMaxCount != '') {
                        document.getElementById("pileBrandMaxCount").innerHTML = data.data.pileBrandMaxCount;
                    } else {
                        document.getElementById("pileBrandMaxCount").innerHTML = "-";
                    }
                    if (data.data.pileStationMaxCount != null && data.data.pileStationMaxCount != '') {
                        document.getElementById("pileStationMaxCount").innerHTML = data.data.pileStationMaxCount;
                    } else {
                        document.getElementById("pileStationMaxCount").innerHTML = '-';
                    }
                    if (data.data.pileOnlineRate != null && data.data.pileOnlineRate != '') {
                        document.getElementById("pileOnlineRate").innerHTML = data.data.pileOnlineRate;
                    } else {
                        document.getElementById("pileOnlineRate").innerHTML = '0';
                    }
                } else {
                    layer.msg(data.message);
                }
            }
        });
    }

    selectPileOffineStatistics()

    // $("#sort").change(function () {
    //     pileOffline.reLoad()
    // })

    getDate()

    pileOffline.init();
</script>
</body>
</html>
<script>
    // //日期范围限制
    var start = {
        elem: '#beginTime',
        format: 'YYYY-MM-DD hh:mm:ss',
        // theme: '#3195f0',
        // min: laydate.now(), //设定最小日期为当前日期
        // max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            $("#endTime").val("")
            end.min = datas
        }
    };
    var end = {
        elem: '#endTime',
        format: 'YYYY-MM-DD hh:mm:ss',
        // theme: '#3195f0',
        // min: laydate.now(),
        // max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
    laydate.skin('molv');//皮肤
</script>
